<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddReduceAmountToRepayRecordMoneys extends Migration
{
    private $table = 'repay_record_moneys';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table($this->table, function (Blueprint $table) {
            $table->unsignedInteger('relief_amount')->default(0)->comment('减免金额,以分为单位')->after('repayment_money');
            $table->unsignedInteger('discount_amount')->default(0)->comment('折扣金额,以分为单位')->after('relief_amount');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if(Schema::hasTable($this->table)){
            Schema::table($this->table, function (Blueprint $table) {
                $table->dropColumn('relief_amount');
                $table->dropColumn('discount_amount');
            });
        }
    }
}
